import Vue from "vue";
import VueRouter from "vue-router";
import Home from "pages/Home/Home.vue";
import User from "pages/User/User.vue";
import Search from "pages/Search/Search.vue";
import Detailq from "pages/Detailq/Detailq.vue";
import Detail from "pages/Detail/Detail.vue";
import Artist from "pages/Artist/Artist.vue";
import Toplist from "pages/Toplist/Toplist.vue";
import Category from "pages/Category/Category.vue";

Vue.use(VueRouter);

const routes = [
  // 通过嵌套路由实现
  {
    path: "/",
    component: Home,
  },
  {
    path: "/artist",
    component: Artist,
  },
  {
    path: "/toplist",
    component: Toplist,
  },
  {
    path: "/category",
    component: Category,
  },
  {
    path: "/search",
    name: "search",
    component: Search,
  },
  {
    path: "/user",
    component: User,
  },
  {
    path: "/detail/:mid",
    component: Detail,
  },
  {
    path: "/detailq/:id",
    component: Detailq,
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
  scrollBehavior(to, from, savePosition) {
    //页面跳转详情后返回还在之前滚动高度
    return savePosition; // 滚动条高度
  },
});

export default router;
